package com.neusoft.elm;

import java.util.Scanner;

import com.neusoft.elm.View.BusinessView;
import com.neusoft.elm.View.FoodView;
import com.neusoft.elm.View.impl.BusinessViewImpl;
import com.neusoft.elm.View.impl.FoodViewImpl;
import com.neusoft.elm.po.Business;

public class ElmBusinessEnty {

	//商家业务流程
	public void work(){
		Scanner sc = new Scanner(System.in);
			
		System.out.println("-----------------------------------------------------------------");
		System.out.println("|\t\t\t 饿了么后台管理系统 \t\t\t|");
		System.out.println("-----------------------------------------------------------------");
		
		//声明视图对象
		BusinessView businessView = new BusinessViewImpl();
		//商家登录
		
		Business business = businessView.login();
		if(business!=null){

			
			int menu = 0;/*menu(菜单)*/
			//只要选项不是5，程序就不退出，始终循环
			while(menu !=5 ){
				System.out.println("\n======= 一级菜单（商家管理）1.查看商家信息=2.修改商家信息=3.更新密码=4.所属商品管理=5.退出系统=======");
				System.out.println("请输入您想进入的操作菜单：");
				menu = sc.nextInt();
				switch(menu){
				    case 1:
				    	//System.out.println("1.查看商家信息");
				    	businessView.showBusiness(business.getBusinessId());
				    	break;
				    case 2:
				    	//System.out.println("2.修改商家信息");
				    	businessView.editBusiness(business.getBusinessId());
				    	break;
				    case 3:
				    	//System.out.println("3.更新密码");
				    	businessView.updateBusinessByPassword(business.getBusinessId());
				    	break;
				    case 4:
				    	//System.out.println("4.所属商品管理");
				    	foodMannager(business.getBusinessId());
				    	break;
				    case 5:
				    	System.out.println("5.退出系统");
				    	break;
				    default:
				    	System.out.println("404 Not Found");
				    	break;
				}
			}
			
		}else{
			System.out.println("登录失败，请检查商家编号或密码");
		}
			
	}
	public void foodMannager(int businessId){
		
		Scanner input = new Scanner(System.in);
		FoodView foodView = new FoodViewImpl();
		
		int menu = 0;
		Integer foodId = 0;
		//只要选项不是5，程序就不退出，始终循环
		while(menu !=5 ){
			System.out.println("\n======= 二级菜单（食品管理）1.查看食品列表=2.新增食品=3.修改食品=4.删除食品=5.返回一级菜单 =======");
			System.out.println("请输入您想进入的操作菜单：");
			menu = input.nextInt();
			switch(menu){
			    case 1:
			    	//System.out.println("1.查看食品列表");
			    	foodView.showFoodList(businessId);
			    	break;
			    case 2:
			    	//System.out.println("2.新增食品");
			    	foodView.saveFood(businessId);
			    	break;
			    case 3:
			    	//System.out.println("3.修改食品");
			    	foodView.updateFood(businessId);
			    	break;
			    case 4:
			    	//System.out.println("4.删除食品");
			    	foodView.removeFood(businessId);
			    	break;
			    case 5:
			    	System.out.println("5.返回一级菜单");
			    	break;
			    default:
			    	System.out.println("404 Not Found");
			    	break;
			}
		}
		
	}
	
	
	public static void main(String[] args) {
		new ElmBusinessEnty().work();
	}

}
